import sys,os
sys.path.append("..")

import unittest

from ensemble.vote import *

class testsumrule(unittest.TestCase):
    """
    majorityresultlevel3(fl,"sum")
    """
    filelist = [os.path.abspath('.').replace("\\","/")+"/ensembledata/svsm.txt",
                os.path.abspath('.').replace("\\","/")+"/ensembledata/postfidf.txt"]
    
    def testpredictclass(self):
        cresult = majorityrulelevel3(self.filelist,"sum")
        self.assertEqual(cresult[5]['predictclass'],1)
        self.assertEqual(cresult[8]['predictclass'],1)
        self.assertEqual(cresult[9]['predictclass'],1)        

    def testtrueclass(self):
        cresult = majorityrulelevel3(self.filelist,"sum")
        self.assertEqual(cresult[1]['trueclass'],3)
        self.assertEqual(cresult[10]['trueclass'],3)
        self.assertEqual(cresult[15]['trueclass'],3)

    def testdis(self):
        cresult = majorityrulelevel3(self.filelist,"sum")
        self.assertEqual(cresult[4]['dis'][3],0.516)

if __name__ == "__main__":
    unittest.main()
